React route <Link To> is not working in maven springboot project
NickName:Nithila Ask DateTime:2016-08-23T13:05:09

React route <Link To> is not working in maven springboot project

I have created a maven spring boot project with React, when i run the webpack the Link to works perfectly, when i try to run with mvn spring-boot run, it throws an error 404 and page not found,

My client.js,

import React from 'react';
import { render } from 'react-dom';
import { Route,Router, browserHistory} from 'react-router';
import Home from './components/Home';
import About from './components/About';

render((
    <Router history={browserHistory}>
        <Route path="/Home" component={Home}></Route>
        <Route path="/about" component={About}></Route>
    </Router>

), document.getElementById('reactDiv'));                                                                                                        

Home component,

import React from 'react';

export default class Home extends React.Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <div>
            <h2> Home Page </h2>
            <Link to={`/about`} target="_blank"> 
                About
            </Link>
      </div>
    );
  }
}

About component,

import React from 'react';

export default class About extends React.Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <div>
            <h2> About Page </h2>
      </div>
    );
  }
}

Copyright Notice:Content Author:「Nithila」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/39092749/react-route-link-to-is-not-working-in-maven-springboot-project

More about “React route <Link To> is not working in maven springboot project” related questions

React issue with route

I have started to experiment with react following this tutorial: http://courses.reactjsprogram.com/ I have the following code for my route.s var React = require('react'); var ReactRouter = require('

Show Detail

React route is not working | React Router

I install npm install react-router-dom@6 and set route path.. import React from &quot;react&quot;; import * as ReactDOM from &quot;react-dom&quot;; import { BrowserRouter, Switch, Route } from &quot;

Show Detail

React route is not working | React Router

I install npm install react-router-dom@6 and set route path.. import React from &quot;react&quot;; import * as ReactDOM from &quot;react-dom&quot;; import { BrowserRouter, Switch, Route } from &quot;

Show Detail

react Private Route

I'm trying to apply privateRoute but it's not working at all either the component or the redirecting I tried also using children like documentation but same issue. React doesn't read Component and...

Show Detail

React dom route

Here is my App.js code import './App.css'; import Home from './Pages/Home'; import About from './Pages/About'; import Contact from './Pages/Contact'; import {BrowserRouter,Routes,Route ,Link} fro

Show Detail

React Router conditioning by Route

I'm using React Router for server side rendering and I'd like to run a special action on certain Route, actually on DefaultRoute. How should I create condition for that? I tried following code: var

Show Detail

React Route With Params Location for route cannot be found

Upon finding a solution for an issue I was having I came across another issue. After adding a route param on to my route, react router doesn't recognize it anymore. Component rendering new route ...

Show Detail

React Route URL

I'm new with React. I'm using react-router-dom. import React from 'react'; import { Router, Route, Switch, Link } from 'react-router-dom'; import Home from './components/home'; import Login from

Show Detail

React nested route not mounting

I want my routes to look like: / /signin /discussion/:title However, anything past the second forward slash causes an error, and all of my client-side dependencies are throwing Unexpected token e...

Show Detail

private route in react

I'm using React Router v6 and am creating private routes for my application. i must to close all routes except login until user is authenticated this is my private route import React from 'react'; ...

Show Detail